//
//  AppointmentViewController.m
//  WE
//
//  Created by apple on 15/12/4.
//  Copyright © 2015年 UNOHACHA. All rights reserved.
//

#import "AppointmentViewController.h"
#import "Size.h"
#import "ToolUtil.h"
#import "AppointCell.h"
#import "TitleLineCell.h"
#import "AuthenticateControl.h"
@interface AppointmentViewController ()<UITableViewDelegate, UITableViewDataSource>

@end

@implementation AppointmentViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.title = @"预约";
    self.view.backgroundColor = [UIColor whiteColor];
    UITableView *tableV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, WindowHeight)style:UITableViewStyleGrouped];
    
    tableV.delegate = self;
    tableV.dataSource = self;
    tableV.showsVerticalScrollIndicator = NO;
    [self.view addSubview:tableV];
    
    
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (!section) {
        return 5;
    }
    
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 40;
    }
    return 60;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    if (indexPath.row == 0) {
        TitleLineCell * cell = [[TitleLineCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    AppointCell * cell = [[AppointCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"提示" message:@"暂未登录请实名认证" preferredStyle:(UIAlertControllerStyleAlert)];
    UIAlertAction * enterAction = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
                [self.navigationController pushViewController:[[AuthenticateControl alloc] init] animated:YES];
            }];
    UIAlertAction * cancellAction = [UIAlertAction actionWithTitle:@"取消" style:(UIAlertActionStyleCancel) handler:^(UIAlertAction * _Nonnull action) {
//        [self.navigationController pushViewController:[[AuthenticateControl alloc] init] animated:YES];
    }];
    [alertController addAction:enterAction];
    [alertController addAction:cancellAction];
    [self presentViewController:alertController animated:YES completion:nil];

}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    if (!section) {
        
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, 140)];
        headerView.backgroundColor = GRAYCOLOR;
        UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, 80)];
        view.backgroundColor = [UIColor colorWithRed:0.8378 green:0.5586 blue:0.1428 alpha:1.0];
        UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(10, 10, 60, 60)];
        imageV.layer.masksToBounds = YES;
        imageV.layer.cornerRadius = 30;
        imageV.image = [UIImage imageNamed:@"19D72705-8904-433C-BBA4-299342AFF304"];
        [view addSubview:imageV];
        UILabel *nameL = [[UILabel alloc] initWithFrame:CGRectMake(80, 10, 50, 20)];
        nameL.text = @"蔡医生";
        nameL.textColor = [UIColor whiteColor];
        nameL.font = FONT(14);
        [view addSubview:nameL];
        UILabel *directorL = [[UILabel alloc] initWithFrame:CGRectMake(140, 10, 50, 20)];
        
        directorL.text = @"主任医师";
        directorL.textColor = [UIColor whiteColor];
        directorL.font = FONT(12);
        [view addSubview:directorL];
        UILabel *hLabel = [[UILabel alloc] initWithFrame:CGRectMake(80, 35, WindowWidth / 3 * 2, 20)];
        hLabel.text = @"中国人民解放军总医院301医院";
        hLabel.textColor = [UIColor whiteColor];
        hLabel.font = FONT(12);
        [view addSubview:hLabel];
        UILabel *deskL = [[UILabel alloc] initWithFrame:CGRectMake(80, 60, 100, 20)];
        deskL.text = @"消化科";
        deskL.textColor = [UIColor whiteColor];
        deskL.font = FONT(12);
        [view addSubview:deskL];
        UILabel *numberL = [[UILabel alloc] initWithFrame:CGRectMake(WindowWidth - 60, 30, 60, 15)];
        numberL.text = @"1332";
        numberL.textAlignment = NSTextAlignmentCenter;
        numberL.font = FONT(12);
        [view addSubview:numberL];
        UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(WindowWidth-60, 50, 60, 15)];
        label.text = @"预约量";
        label.textAlignment = NSTextAlignmentCenter;
        label.font = FONT(12);
        [view addSubview:label];
        [headerView addSubview:view];
       //[ToolUtil createLine:80 superView:headerView lift:0 width:WindowWidth hight:10 color:GRAYCOLOR];
        UIView *butView = [[UIView alloc] initWithFrame:CGRectMake(0, 90, WindowWidth, 40)];
        butView.backgroundColor = [UIColor whiteColor];
        UILabel *titleL = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, WindowWidth - 90, 40)];
        titleL.numberOfLines = 2;
        titleL.text = @"徐卫星专家团队将根据您的病情分配医生初诊\n疾病要求:颈椎病,腰椎滑脱";
        titleL.textColor = BLACKCOLOR;
        titleL.font = FONT(12);
        [butView addSubview:titleL];
        UIButton *lButton = [UIButton buttonWithType:UIButtonTypeCustom];
        lButton.frame = CGRectMake(WindowWidth - 70, 5, 65, 30);
        
        [lButton setTitle:@"对症预约" forState:UIControlStateNormal];
        lButton.titleLabel.font = FONT(14);
        [lButton addTarget:self action:@selector(docik) forControlEvents:UIControlEventTouchUpInside];
        lButton.backgroundColor = [UIColor orangeColor];
        [lButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        [butView addSubview:lButton];
        [headerView addSubview:butView];
        
        
        return headerView;
    }
    
    UIView *headerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, WindowWidth, 300)];
    headerV.backgroundColor = [UIColor whiteColor];
//    [ToolUtil createLine:0 superView:headerV lift:0 width:WindowWidth hight:10 color:GRAYCOLOR];
    CGFloat wid = [ToolUtil autoWidth:@"医院平台预约规则" width:0 height:20 num:14];
    UILabel *rule = [[UILabel alloc] initWithFrame:CGRectMake(15, 25, wid, 20)];
    rule.font = FONT(14);
    rule.text = @"医院平台预约规则";
    rule.textColor = BLACKCOLOR;
    rule.backgroundColor = [UIColor whiteColor];
    [headerV addSubview:rule];
    CGFloat width = [ToolUtil autoWidth:@"(班次每日00:00更新)" width:0 height:20 num:14];
    
    UILabel *dayL =[[UILabel alloc] initWithFrame:CGRectMake(wid + 25, 25, width, 20)];
    dayL.text = @"(班次每日00:00更新)";
    dayL.font = FONT(14);
    dayL.textColor = [UIColor blueColor];
    dayL.backgroundColor = [UIColor whiteColor];
    [headerV addSubview:dayL];
    UILabel *hRule = [[UILabel alloc] initWithFrame:CGRectMake(15, 60, 100, 20)];
    hRule.text = @"医院规则";
    hRule.textColor = [UIColor grayColor];
    hRule.font = FONT(14);
    [headerV addSubview:hRule];
    
    UILabel *hospitalR = [[UILabel alloc] initWithFrame:CGRectMake(15, 80, WindowWidth-15, 60)];
    hospitalR.numberOfLines = 3;
    hospitalR.text = @"1、预约周期: 1-7天内。2、取消时限: 就诊前一日15:00前。3、取号: 请按照预约时间取号提前半小时凭预约证件及取号密码。";
    hospitalR.textColor = [UIColor grayColor];
    hospitalR.font = FONT(14);
    [headerV addSubview:hospitalR];
    
    return headerV;
    

}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
        return 140;
}

- (void)docik{
    [self.navigationController pushViewController:[[AuthenticateControl alloc] init] animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
